//取出token
let token = JSON.parse(localStorage.getItem('token'))
layui.form.on('submit(formDemo)', function(data) {
    console.log(data.field)

    //修改密码
    resetPwd(token, data.field.oldpwd, data.field.newpwd, function(data) {
        layer.msg(data.message)

        //重置表单
        $('[type="reset"]').trigger('click')
    }, function() {
        layer.msg(data.message)
    })
    return false
})

layui.form.verify({
    pwd: [/^[\S]{6,12}$/, '请输入6-12位密码'],
    repwd: function(value, item) {
        if ($('[name="newpwd"]').val() !== value) {
            return ('两次密码不一致')
        }
    },
    same: function(value, item) {
        if ($('[name="oldpwd"]').val() === value) {
            return ('和原密码不能相同')
        }
    }
})